//
//  ChangePasswordApi.m
//  SYDoorLock
//
//  Created by maple on 2016/11/4.
//  Copyright © 2016年 maplexk. All rights reserved.
//

#import "ChangePasswordApi.h"

@implementation ChangePasswordApi{
    NSDictionary *_dic;
}

-(id)initWithDic:(NSDictionary *)dic{
    if (self = [super init]) {
        _dic = dic;
    }
    return self;
}

- (NSString *)requestUrl {
    return @"new/user/change_pwd";
}

- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodPOST;
}

- (id)requestArgument {
    NSMutableDictionary *dic = [NSMutableDictionary getPubdicGuest];
    if (_dic[@"old_pwd"]) {
        
        NSString* base64Text = [NSString encryptUseAES:_dic[@"old_pwd"] key:nil];
        
        [dic setObject:base64Text forKey:@"old_pwd"];
        
    }
    if (_dic[@"new_pwd"]) {
        NSString* base64Text = [NSString encryptUseAES:_dic[@"new_pwd"] key:nil];
        
        [dic setObject:base64Text forKey:@"new_pwd"];
        
    }
    if (_dic[@"token"]) {
        [dic setObject:_dic[@"token"] forKey:@"token"];
        
    }
    if (_dic[@"uid"]) {
        [dic setObject:_dic[@"uid"] forKey:@"uid"];
        
    }
    NSString *sign=[NSString getSign:dic];
    [dic setObject:sign forKey:@"sign"];
    return dic;
    
}

- (NSString *)userId {
    return [[[self responseJSONObject] objectForKey:@"userId"] stringValue];
}

-(void)analyseResponseObject {
    NSDictionary * dict = [self responseJSONObject];
    NSLog(@"dict = %@",dict);
    if ([dict[@"errcode"] intValue] == 0) {
        
        [SVProgressHUD showSuccessWithStatus:@"修改密码成功！"];
      
    } else {
        
        [SVProgressHUD showErrorWithStatus:dict[@"errmsg"]];
    }
}

-(void)dealloc
{
    NSLog(@"ChangePasswordApi dealloc");
}


@end
